package com.macro.client.service.impl;

import com.macro.client.service.AddressService;
import com.macro.client.utils.AddressParse;
import com.macro.mall.mapper.UmsMemberReceiveAddressMapper;
import com.macro.mall.model.UmsMemberReceiveAddress;
import com.macro.mall.model.UmsMemberReceiveAddressExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName AddressServiceImpl
 * @Description 描述
 * @Author bai
 * @Date 2024/10/23 10:06
 */

@Service
public class AddressServiceImpl implements AddressService {

    @Autowired
    private UmsMemberReceiveAddressMapper umsMemberReceiveAddressMapper;

    @Autowired
    private AddressParse addressParse;




    @Override
    public List<UmsMemberReceiveAddress> list() {
        return umsMemberReceiveAddressMapper.selectByExample(new UmsMemberReceiveAddressExample());
    }

    @Override
    public void add(UmsMemberReceiveAddress umsMemberReceiveAddress) {
        umsMemberReceiveAddressMapper.insert(umsMemberReceiveAddress);
    }

    @Override
    public UmsMemberReceiveAddress find(Integer id) {
        return umsMemberReceiveAddressMapper.selectByPrimaryKey(Long.valueOf(id));
    }

    @Override
    public void update(UmsMemberReceiveAddress umsMemberReceiveAddress) {
        umsMemberReceiveAddressMapper.updateByPrimaryKeySelective(umsMemberReceiveAddress);
    }

    @Override
    public void delete(Integer id) {
        umsMemberReceiveAddressMapper.deleteByPrimaryKey(Long.valueOf(id));
    }

    @Override
    public UmsMemberReceiveAddress string2Addr(String addr) {
        return addressParse.parse(addr);
    }


}
